package com.hospital.workstation.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import com.hospital.workstation.domain.vo.CareLevelTriggerItemVo;
import lombok.RequiredArgsConstructor;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;

import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.hospital.common.annotation.RepeatSubmit;
import com.hospital.common.annotation.Log;
import com.hospital.common.core.controller.BaseController;
import com.hospital.common.core.domain.PageQuery;
import com.hospital.common.core.domain.R;
import com.hospital.common.core.validate.AddGroup;
import com.hospital.common.core.validate.EditGroup;
import com.hospital.common.core.validate.QueryGroup;
import com.hospital.common.enums.BusinessType;
import com.hospital.common.utils.poi.ExcelUtil;
import com.hospital.workstation.domain.vo.FirstLevelVo;
import com.hospital.workstation.domain.bo.FirstLevelBo;
import com.hospital.workstation.service.IFirstLevelService;
import com.hospital.common.core.page.TableDataInfo;

/**
 * 医学一级监护信息
 *
 * @author whb
 * @date 2023-04-18
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/workstation/firstLevel")
public class FirstLevelController extends BaseController {

    private final IFirstLevelService iFirstLevelService;

    /**
     * 获取医学一级监护信息详细信息
     *
     * @param medicalRecordNo 病历号
     * @return
     */
    @GetMapping("/{medicalRecordNo}")
    public R<FirstLevelVo> getInfo(@NotNull(message = "病历号不能为空") @PathVariable Integer medicalRecordNo) {
        return R.ok(iFirstLevelService.queryByMedicalRecordNo(medicalRecordNo));
    }

    /**
     * 新增或修改一级监护信息
     *
     * @param bo 一级监护业务对象
     * @return
     */
    @Log(title = "医学一级监护信息", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> addOrUpdate(@Validated(AddGroup.class) @RequestBody FirstLevelBo bo) {
        return toAjax(iFirstLevelService.insertOrUpdateByBo(bo));
    }

    /**
     * 获取医学监护标红项信息
     *
     * @param medicalRecordNo 病历号
     * @return
     */
    @GetMapping("/red/{medicalRecordNo}")
    public R<CareLevelTriggerItemVo> queryRedItem(@NotNull(message = "病历号不能为空") @PathVariable Integer medicalRecordNo) {
        return iFirstLevelService.getRedItemVo(medicalRecordNo);
    }
}
